package com.cy.pj.sys.web.controller;

import com.cy.pj.common.pojo.JsonResult;
import com.cy.pj.sys.pojo.SysUser;
import com.cy.pj.sys.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user/")
public class SysUserController {
    @Autowired
    private SysUserService sysUserService;
    @GetMapping
    public JsonResult doFindUsers(SysUser sysUser){
        return new JsonResult(sysUserService.findUsers(sysUser));
    }
    @GetMapping("{id}")
    public JsonResult doFindById(@PathVariable Integer id){
        return new JsonResult(sysUserService.findById(id));
    }
    @PostMapping()
    public JsonResult doSaveUsers(@RequestBody SysUser sysUser){
        sysUserService.saveUser(sysUser);
        return new JsonResult("save ok!");
    }
    @PutMapping
    public JsonResult doUpdateUsers(@RequestBody SysUser sysUser){
        sysUserService.updateUser(sysUser);
        return new JsonResult("update ok!");
    }
    @PatchMapping("{id}/{valid}")
    public JsonResult doValidById(@PathVariable Integer id,@PathVariable Integer valid){
        sysUserService.validById(id,valid);
        return new JsonResult("update ok!");
    }
}
